//
//  DDLoginSuccessCell.m
//  PrivateCloud
//
//  Created by sarah doo on 13-10-13.
//  Copyright (c) 2013年 sarah doo. All rights reserved.
//

#import "DDLoginSuccessCell.h"
#import "UIColor+.h"

@implementation DDLoginSuccessCell

@synthesize model, nameLabel, addressLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}

- (void)createViews {
    NSLog(@"%f",self.frame.size.width);
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 10)];
    topView.backgroundColor = [UIColor colorWithString:@"#273826"];
    [self.contentView addSubview:topView];
    [topView release];
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, self.frame.size.width, self.frame.size.height - 10)];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgView];
    
    UIImage *image = [UIImage imageNamed:@"device.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 5, 30, 30)];
    [imageView setImage:image];
    [bgView addSubview:imageView];
    [imageView release];
    
    nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 5, 300, 30)];
    nameLabel.backgroundColor = [UIColor clearColor];
    [bgView addSubview:nameLabel];
    
    addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 50, 300, 30)];
    addressLabel.backgroundColor = [UIColor clearColor];
    [bgView addSubview:addressLabel];

}

- (void)setModel:(DDLoginSuccessModel *)_model {
    if (model != _model) {
        [model release];
        model = [_model retain];
    }
    nameLabel.text = model.IPName;
    addressLabel.text = model.IPAddress;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
